/**
 *
 */
import OSS;
import OpenPlatform;
import OSSUtil;
import FileForm;
import OpenApi;
import OpenApi.OpenApiUtil;

extends OpenApi;


init(config: OpenApiUtil.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('cloudauth-intl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!$isNull(endpoint)) {
    return endpoint;
  }
  
  if (!$isNull(endpointMap) && !$isNull(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return OpenApiUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CardOcrRequest {
  docType?: string(name='DocType', example='00000006'),
  idFaceQuality?: string(name='IdFaceQuality', example='F'),
  idOcrPictureBase64?: string(name='IdOcrPictureBase64'),
  idOcrPictureUrl?: string(name='IdOcrPictureUrl', example='https://digital-cardocr-prod8.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  merchantBizId?: string(name='MerchantBizId', example='dso9322***dsjsd22'),
  merchantUserId?: string(name='MerchantUserId', example='123456789'),
  ocr?: string(name='Ocr', example='T'),
  productCode?: string(name='ProductCode', example='ID_OCR_MIN'),
  spoof?: string(name='Spoof', example='F'),
}

model CardOcrResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB356FE-BB6A-5DCC-B4C5-E8051787EBA1'),
  result?: {
    extCardInfo?: string(name='ExtCardInfo'),
    extIdInfo?: string(name='ExtIdInfo'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='200'),
    transactionId?: string(name='TransactionId', example='08573be80f944d95ac812e019e3655a8'),
  }(name='Result'),
}

model CardOcrResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CardOcrResponseBody(name='body'),
}

/**
 * @deprecated OpenAPI CardOcr is deprecated, please use Cloudauth-intl::2022-08-09::DocOcr instead.
 *
 * @summary 证件OCR识别纯服务端接口
 *
 * @param request CardOcrRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CardOcrResponse
 */
// Deprecated
async function cardOcrWithOptions(request: CardOcrRequest, runtime: $RuntimeOptions): CardOcrResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.docType)) {
    query['DocType'] = request.docType;
  }
  if (!$isNull(request.idFaceQuality)) {
    query['IdFaceQuality'] = request.idFaceQuality;
  }
  if (!$isNull(request.idOcrPictureUrl)) {
    query['IdOcrPictureUrl'] = request.idOcrPictureUrl;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    query['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.ocr)) {
    query['Ocr'] = request.ocr;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.spoof)) {
    query['Spoof'] = request.spoof;
  }
  var body : map[string]any = {};
  if (!$isNull(request.idOcrPictureBase64)) {
    body['IdOcrPictureBase64'] = request.idOcrPictureBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CardOcr',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @deprecated OpenAPI CardOcr is deprecated, please use Cloudauth-intl::2022-08-09::DocOcr instead.
 *
 * @summary 证件OCR识别纯服务端接口
 *
 * @param request CardOcrRequest
 * @return CardOcrResponse
 */
// Deprecated
async function cardOcr(request: CardOcrRequest): CardOcrResponse {
  var runtime = new $RuntimeOptions{};
  return cardOcrWithOptions(request, runtime);
}

model CheckResultRequest {
  extraImageControlList?: string(name='ExtraImageControlList', example='***'),
  isReturnImage?: string(name='IsReturnImage', example='N'),
  merchantBizId?: string(name='MerchantBizId', example='djs20d***9-dsskc'),
  returnFiveCategorySpoofResult?: string(name='ReturnFiveCategorySpoofResult', example='Y'),
  transactionId?: string(name='TransactionId', example='4ab0b***cbde97'),
}

model CheckResultResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB35****87EBA1'),
  result?: {
    ekycResult?: string(name='EkycResult', example='**'),
    extBasicInfo?: string(name='ExtBasicInfo', example='**'),
    extFaceInfo?: string(name='ExtFaceInfo', example='**'),
    extIdInfo?: string(name='ExtIdInfo', example='**'),
    extInfo?: string(name='ExtInfo'),
    extRiskInfo?: string(name='ExtRiskInfo', example='**'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='***'),
  }(name='Result'),
}

model CheckResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckResultResponseBody(name='body'),
}

/**
 * @summary 结果查询
 *
 * @param request CheckResultRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckResultResponse
 */
async function checkResultWithOptions(request: CheckResultRequest, runtime: $RuntimeOptions): CheckResultResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.extraImageControlList)) {
    query['ExtraImageControlList'] = request.extraImageControlList;
  }
  if (!$isNull(request.isReturnImage)) {
    query['IsReturnImage'] = request.isReturnImage;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.returnFiveCategorySpoofResult)) {
    query['ReturnFiveCategorySpoofResult'] = request.returnFiveCategorySpoofResult;
  }
  if (!$isNull(request.transactionId)) {
    query['TransactionId'] = request.transactionId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'CheckResult',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 结果查询
 *
 * @param request CheckResultRequest
 * @return CheckResultResponse
 */
async function checkResult(request: CheckResultRequest): CheckResultResponse {
  var runtime = new $RuntimeOptions{};
  return checkResultWithOptions(request, runtime);
}

model CheckVerifyLogRequest {
  merchantBizId?: string(name='MerchantBizId', example='e0c34a***353888'),
  transactionId?: string(name='TransactionId', example='hksb7ba1b*********015d694361bee4'),
}

model CheckVerifyLogResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB35****87EBA1'),
  result?: {
    extInfo?: string(name='ExtInfo', example='{}'),
    interruptPage?: string(name='InterruptPage'),
    logInfo?: [ string ](name='LogInfo'),
    logStatisticsInfo?: string(name='LogStatisticsInfo', example='{
          "faceOverTimes": 0,
          "hasFaceOverTimes": false,
          "hasFacePermissionRefuse": false,
          "hasOcrEdit": true,
          "hasOcrEditOverTimes": false,
          "hasOcrOverTimes": true,
          "hasOcrPermissionRefuse": false,
          "ocrEditOverTimes": 0,
          "ocrEditTimes": 1,
          "ocrOverTimes": 1,
          "pageStayTimeInfo": {
            "LOADING": "1615",
            "OCR_SCAN": "37446",
            "OCR_RESULT": "1338",
            "FACE": "8707"
          }
        }'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='200'),
    verifyErrorCode?: string(name='VerifyErrorCode', example='1001'),
    verifyStatus?: string(name='VerifyStatus', example='1'),
  }(name='Result'),
}

model CheckVerifyLogResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CheckVerifyLogResponseBody(name='body'),
}

/**
 * @summary 认证日志查询接口
 *
 * @param request CheckVerifyLogRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CheckVerifyLogResponse
 */
async function checkVerifyLogWithOptions(request: CheckVerifyLogRequest, runtime: $RuntimeOptions): CheckVerifyLogResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.merchantBizId)) {
    body['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.transactionId)) {
    body['TransactionId'] = request.transactionId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CheckVerifyLog',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 认证日志查询接口
 *
 * @param request CheckVerifyLogRequest
 * @return CheckVerifyLogResponse
 */
async function checkVerifyLog(request: CheckVerifyLogRequest): CheckVerifyLogResponse {
  var runtime = new $RuntimeOptions{};
  return checkVerifyLogWithOptions(request, runtime);
}

model CredentialVerifyIntlRequest {
  credName?: string(name='CredName', description='This parameter is required.', example='0101'),
  credType?: string(name='CredType', description='This parameter is required.', example='01'),
  imageFile?: string(name='ImageFile'),
  imageUrl?: string(name='ImageUrl', example='https://oss-bj01.avic.com/eavic-prod-commodity/pic/commodity/94677ee6-1067-4287-8ff4-6e030ef3a5a8.jpg'),
  productCode?: string(name='ProductCode', description='This parameter is required.'),
}

model CredentialVerifyIntlAdvanceRequest {
  credName?: string(name='CredName', description='This parameter is required.', example='0101'),
  credType?: string(name='CredType', description='This parameter is required.', example='01'),
  imageFileObject?: readable(name='ImageFile'),
  imageUrl?: string(name='ImageUrl', example='https://oss-bj01.avic.com/eavic-prod-commodity/pic/commodity/94677ee6-1067-4287-8ff4-6e030ef3a5a8.jpg'),
  productCode?: string(name='ProductCode', description='This parameter is required.'),
}

model CredentialVerifyIntlResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='130A2C10-B9EE-4D84-88E3-5384FF039795'),
  resultObject?: {
    materialInfo?: string(name='MaterialInfo'),
    result?: string(name='Result', example='1'),
    riskScore?: map[string]string(name='RiskScore'),
    riskTag?: string(name='RiskTag', example='PS'),
  }(name='ResultObject'),
}

model CredentialVerifyIntlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: CredentialVerifyIntlResponseBody(name='body'),
}

/**
 * @summary 凭证核验
 *
 * @param request CredentialVerifyIntlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return CredentialVerifyIntlResponse
 */
async function credentialVerifyIntlWithOptions(request: CredentialVerifyIntlRequest, runtime: $RuntimeOptions): CredentialVerifyIntlResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.credName)) {
    query['CredName'] = request.credName;
  }
  if (!$isNull(request.credType)) {
    query['CredType'] = request.credType;
  }
  if (!$isNull(request.imageUrl)) {
    query['ImageUrl'] = request.imageUrl;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  var body : map[string]any = {};
  if (!$isNull(request.imageFile)) {
    body['ImageFile'] = request.imageFile;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'CredentialVerifyIntl',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 凭证核验
 *
 * @param request CredentialVerifyIntlRequest
 * @return CredentialVerifyIntlResponse
 */
async function credentialVerifyIntl(request: CredentialVerifyIntlRequest): CredentialVerifyIntlResponse {
  var runtime = new $RuntimeOptions{};
  return credentialVerifyIntlWithOptions(request, runtime);
}

async function credentialVerifyIntlAdvance(request: CredentialVerifyIntlAdvanceRequest, runtime: $RuntimeOptions): CredentialVerifyIntlResponse {
  // Step 0: init client
  var accessKeyId = @credential.getAccessKeyId();
  var accessKeySecret = @credential.getAccessKeySecret();
  var securityToken = @credential.getSecurityToken();
  var credentialType = @credential.getType();
  var openPlatformEndpoint = @openPlatformEndpoint;
  if($isNull(openPlatformEndpoint)) {
    openPlatformEndpoint ='openplatform.aliyuncs.com';
  }
  if($isNull(credentialType)) {
    credentialType ='access_key';
  }
  var authConfig = new OpenApiUtil.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    securityToken = securityToken,
    type = credentialType,
    endpoint = openPlatformEndpoint,
    protocol = @protocol,
    regionId = @regionId,
  };
  var authClient = new OpenPlatform(authConfig);
  var authRequest = new OpenPlatform.AuthorizeFileUploadRequest{
    product = 'Cloudauth-intl',
    regionId = @regionId,
  };
  var authResponse = new OpenPlatform.AuthorizeFileUploadResponse{};
  var ossConfig = new OSS.Config{
    accessKeyId = accessKeyId,
    accessKeySecret = accessKeySecret,
    type = 'access_key',
    protocol = @protocol,
    regionId = @regionId,
  };
  var ossClient : OSS = new OSS(ossConfig);

  var fileObj = new FileForm.FileField{};
  var ossHeader = new OSS.PostObjectRequest.header{};
  var uploadRequest = new OSS.PostObjectRequest{};
  var ossRuntime = new OSSUtil.RuntimeOptions{};
  OpenApiUtil.convert(runtime, ossRuntime);
  var credentialVerifyIntlReq = new CredentialVerifyIntlRequest{};
  OpenApiUtil.convert(request, credentialVerifyIntlReq);

  if(!$isNull(request.imageFileObject)) {
    authResponse = authClient.authorizeFileUploadWithOptions(authRequest, runtime);
    ossConfig.accessKeyId = authResponse.body.accessKeyId;
    ossConfig.endpoint = OpenApiUtil.getEndpoint(authResponse.body.endpoint, authResponse.body.useAccelerate, @endpointType);
    ossClient = new OSS(ossConfig);

    fileObj = new FileForm.FileField{
      filename = authResponse.body.objectKey,
      content = request.imageFileObject,
      contentType = '',
    };
    ossHeader = new OSS.PostObjectRequest.header{
      accessKeyId = authResponse.body.accessKeyId,
      policy = authResponse.body.encodedPolicy,
      signature = authResponse.body.signature,
      key = authResponse.body.objectKey,
      file = fileObj,
      successActionStatus = '201',
    };
    uploadRequest = new OSS.PostObjectRequest{
      bucketName = authResponse.body.bucket,
      header = ossHeader,
    };
    ossClient.postObject(uploadRequest, ossRuntime);
    credentialVerifyIntlReq.imageFile = `http://${authResponse.body.bucket}.${authResponse.body.endpoint}/${authResponse.body.objectKey}`;
  }
  var credentialVerifyIntlResp = credentialVerifyIntlWithOptions(credentialVerifyIntlReq, runtime);
  return credentialVerifyIntlResp;
}

model DeepfakeDetectIntlRequest {
  faceBase64?: string(name='FaceBase64', example='/9j/4AAQSkZJRgABAQAASxxxxxxx'),
  faceInputType?: string(name='FaceInputType', example='IMAGE'),
  faceUrl?: string(name='FaceUrl', example='https://cn-shanghai-aliyun-cloudauth-xxxxxx.oss-cn-shanghai.aliyuncs.com/verify/xxxxx/xxxxx.jpeg'),
  merchantBizId?: string(name='MerchantBizId', description='This parameter is required.', example='e0c34a77f5ac40a5aa5e6ed20c******'),
  productCode?: string(name='ProductCode', description='This parameter is required.', example='FACE_DEEPFAKE'),
  sceneCode?: string(name='SceneCode', example='1234567890'),
}

model DeepfakeDetectIntlResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='8FC3D6AC-9FED-4311-8DA7-C4BF47D9F260'),
  resultObject?: {
    result?: string(name='Result', example='1'),
    riskScore?: map[string]string(name='RiskScore'),
    riskTag?: string(name='RiskTag', example='SuspectDeepForgery,SuspectWarterMark'),
  }(name='ResultObject'),
}

model DeepfakeDetectIntlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeepfakeDetectIntlResponseBody(name='body'),
}

/**
 * @summary 人脸凭证核验
 *
 * @param request DeepfakeDetectIntlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeepfakeDetectIntlResponse
 */
async function deepfakeDetectIntlWithOptions(request: DeepfakeDetectIntlRequest, runtime: $RuntimeOptions): DeepfakeDetectIntlResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.faceInputType)) {
    query['FaceInputType'] = request.faceInputType;
  }
  if (!$isNull(request.faceUrl)) {
    query['FaceUrl'] = request.faceUrl;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.sceneCode)) {
    query['SceneCode'] = request.sceneCode;
  }
  var body : map[string]any = {};
  if (!$isNull(request.faceBase64)) {
    body['FaceBase64'] = request.faceBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeepfakeDetectIntl',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 人脸凭证核验
 *
 * @param request DeepfakeDetectIntlRequest
 * @return DeepfakeDetectIntlResponse
 */
async function deepfakeDetectIntl(request: DeepfakeDetectIntlRequest): DeepfakeDetectIntlResponse {
  var runtime = new $RuntimeOptions{};
  return deepfakeDetectIntlWithOptions(request, runtime);
}

model DeleteVerifyResultRequest {
  deleteAfterQuery?: string(name='DeleteAfterQuery', example='Y / N'),
  deleteType?: string(name='DeleteType', example='Img / Text / All'),
  transactionId?: string(name='TransactionId', example='4ab0b***cbde97'),
}

model DeleteVerifyResultResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='4EB35****87EBA1'),
  result?: {
    deleteResult?: string(name='DeleteResult', example='Y/N'),
    transactionId?: string(name='TransactionId', example='4ab0b***cbde97'),
  }(name='Result'),
}

model DeleteVerifyResultResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DeleteVerifyResultResponseBody(name='body'),
}

/**
 * @summary 删除用户认证记录结果
 *
 * @param request DeleteVerifyResultRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DeleteVerifyResultResponse
 */
async function deleteVerifyResultWithOptions(request: DeleteVerifyResultRequest, runtime: $RuntimeOptions): DeleteVerifyResultResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.deleteAfterQuery)) {
    query['DeleteAfterQuery'] = request.deleteAfterQuery;
  }
  if (!$isNull(request.deleteType)) {
    query['DeleteType'] = request.deleteType;
  }
  if (!$isNull(request.transactionId)) {
    query['TransactionId'] = request.transactionId;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'DeleteVerifyResult',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 删除用户认证记录结果
 *
 * @param request DeleteVerifyResultRequest
 * @return DeleteVerifyResultResponse
 */
async function deleteVerifyResult(request: DeleteVerifyResultRequest): DeleteVerifyResultResponse {
  var runtime = new $RuntimeOptions{};
  return deleteVerifyResultWithOptions(request, runtime);
}

model DocOcrRequest {
  cardSide?: string(name='CardSide'),
  docType?: string(name='DocType', example='00000006'),
  idFaceQuality?: string(name='IdFaceQuality', example='F'),
  idOcrPictureBase64?: string(name='IdOcrPictureBase64'),
  idOcrPictureUrl?: string(name='IdOcrPictureUrl', example='https://digital-cardocr-prod8.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  idThreshold?: string(name='IdThreshold'),
  merchantBizId?: string(name='MerchantBizId', example='dso9322***dsjsd22'),
  merchantUserId?: string(name='MerchantUserId', example='123456789'),
  ocr?: string(name='Ocr', example='T'),
  productCode?: string(name='ProductCode'),
  spoof?: string(name='Spoof', example='F'),
}

model DocOcrResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='86C40EC3-5940-5F47-995C-BFE90B70E540'),
  result?: {
    extIdInfo?: string(name='ExtIdInfo'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='200'),
    transactionId?: string(name='TransactionId', example='08573be80f944d95ac812e019e3655a8'),
  }(name='Result'),
}

model DocOcrResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DocOcrResponseBody(name='body'),
}

/**
 * @summary 卡证ocr纯服务端
 *
 * @param request DocOcrRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DocOcrResponse
 */
async function docOcrWithOptions(request: DocOcrRequest, runtime: $RuntimeOptions): DocOcrResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.cardSide)) {
    query['CardSide'] = request.cardSide;
  }
  if (!$isNull(request.docType)) {
    query['DocType'] = request.docType;
  }
  if (!$isNull(request.idFaceQuality)) {
    query['IdFaceQuality'] = request.idFaceQuality;
  }
  if (!$isNull(request.idOcrPictureUrl)) {
    query['IdOcrPictureUrl'] = request.idOcrPictureUrl;
  }
  if (!$isNull(request.idThreshold)) {
    query['IdThreshold'] = request.idThreshold;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    query['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.ocr)) {
    query['Ocr'] = request.ocr;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.spoof)) {
    query['Spoof'] = request.spoof;
  }
  var body : map[string]any = {};
  if (!$isNull(request.idOcrPictureBase64)) {
    body['IdOcrPictureBase64'] = request.idOcrPictureBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DocOcr',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 卡证ocr纯服务端
 *
 * @param request DocOcrRequest
 * @return DocOcrResponse
 */
async function docOcr(request: DocOcrRequest): DocOcrResponse {
  var runtime = new $RuntimeOptions{};
  return docOcrWithOptions(request, runtime);
}

model DocOcrMaxRequest {
  docType?: string(name='DocType', example='CNSSC01'),
  idOcrPictureBase64?: string(name='IdOcrPictureBase64', example='base64'),
  idOcrPictureUrl?: string(name='IdOcrPictureUrl', example='https://***********.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  idThreshold?: string(name='IdThreshold', example='0'),
  merchantBizId?: string(name='MerchantBizId', example='e0c34a77f5ac40a5aa5e6ed20c******'),
  merchantUserId?: string(name='MerchantUserId', example='123456789'),
  ocrModel?: string(name='OcrModel', example='0'),
  productCode?: string(name='ProductCode', example='ID_OCR_MAX'),
  prompt?: string(name='Prompt'),
  sceneCode?: string(name='SceneCode', example='1234567890'),
  spoof?: string(name='Spoof', example='F'),
}

model DocOcrMaxResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB35****87EBA1'),
  result?: {
    extIdInfo?: string(name='ExtIdInfo', example='{
  "docType": "PPTW01",
  "ocrIdInfo": {
    "passportNo": "36*******",
    "expiryDate": "2032/02/10",
    "placeOfBirth": "TAIWAN",
    "surname": "CHEN",
    "givenname": "LIN-CHUN",
    "countryCode": "TWN",
    "sex": "F",
    "personalNo": "S22********",
    "issueDate": "2022/02/10",
    "birthDate": "1988/10/04"
  }
}'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='200'),
    transactionId?: string(name='TransactionId', example='hk573be80f944d95ac812e0*******a8'),
  }(name='Result'),
}

model DocOcrMaxResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DocOcrMaxResponseBody(name='body'),
}

/**
 * @summary 全球证件ocr识别接口
 *
 * @param request DocOcrMaxRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DocOcrMaxResponse
 */
async function docOcrMaxWithOptions(request: DocOcrMaxRequest, runtime: $RuntimeOptions): DocOcrMaxResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.docType)) {
    body['DocType'] = request.docType;
  }
  if (!$isNull(request.idOcrPictureBase64)) {
    body['IdOcrPictureBase64'] = request.idOcrPictureBase64;
  }
  if (!$isNull(request.idOcrPictureUrl)) {
    body['IdOcrPictureUrl'] = request.idOcrPictureUrl;
  }
  if (!$isNull(request.idThreshold)) {
    body['IdThreshold'] = request.idThreshold;
  }
  if (!$isNull(request.merchantBizId)) {
    body['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    body['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.ocrModel)) {
    body['OcrModel'] = request.ocrModel;
  }
  if (!$isNull(request.productCode)) {
    body['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.prompt)) {
    body['Prompt'] = request.prompt;
  }
  if (!$isNull(request.sceneCode)) {
    body['SceneCode'] = request.sceneCode;
  }
  if (!$isNull(request.spoof)) {
    body['Spoof'] = request.spoof;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'DocOcrMax',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 全球证件ocr识别接口
 *
 * @param request DocOcrMaxRequest
 * @return DocOcrMaxResponse
 */
async function docOcrMax(request: DocOcrMaxRequest): DocOcrMaxResponse {
  var runtime = new $RuntimeOptions{};
  return docOcrMaxWithOptions(request, runtime);
}

model EkycVerifyRequest {
  authorize?: string(name='Authorize', example='T'),
  crop?: string(name='Crop', example='F'),
  docName?: string(name='DocName'),
  docNo?: string(name='DocNo', example='410***************'),
  docType?: string(name='DocType', example='00000001'),
  facePictureBase64?: string(name='FacePictureBase64'),
  facePictureUrl?: string(name='FacePictureUrl', example='https://digital-face-prod8.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  idOcrPictureBase64?: string(name='IdOcrPictureBase64'),
  idOcrPictureUrl?: string(name='IdOcrPictureUrl', example='https://digital-cardocr-prod8.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  idThreshold?: string(name='IdThreshold'),
  merchantBizId?: string(name='MerchantBizId', example='e0c34a77f5ac40a5aa5e6ed20c353888'),
  merchantUserId?: string(name='MerchantUserId', example='123456'),
  productCode?: string(name='ProductCode', example='eKYC_MIN'),
}

model EkycVerifyResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB356FE-BB6A-5DCC-B4C5-E8051787EBA1'),
  result?: {
    extFaceInfo?: string(name='ExtFaceInfo', example='{
"faceAttack": "N",
"faceComparisonScore": 52.57,
"facePassed": "N",
"authorityComparisonScore": 80.39
}'),
    extIdInfo?: string(name='ExtIdInfo'),
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='205'),
    transactionId?: string(name='TransactionId', example='4ab0b***cbde97'),
  }(name='Result'),
}

model EkycVerifyResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: EkycVerifyResponseBody(name='body'),
}

/**
 * @summary ekyc纯服务端接口
 *
 * @param request EkycVerifyRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return EkycVerifyResponse
 */
async function ekycVerifyWithOptions(request: EkycVerifyRequest, runtime: $RuntimeOptions): EkycVerifyResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.authorize)) {
    query['Authorize'] = request.authorize;
  }
  if (!$isNull(request.crop)) {
    query['Crop'] = request.crop;
  }
  if (!$isNull(request.docName)) {
    query['DocName'] = request.docName;
  }
  if (!$isNull(request.docNo)) {
    query['DocNo'] = request.docNo;
  }
  if (!$isNull(request.docType)) {
    query['DocType'] = request.docType;
  }
  if (!$isNull(request.facePictureUrl)) {
    query['FacePictureUrl'] = request.facePictureUrl;
  }
  if (!$isNull(request.idOcrPictureUrl)) {
    query['IdOcrPictureUrl'] = request.idOcrPictureUrl;
  }
  if (!$isNull(request.idThreshold)) {
    query['IdThreshold'] = request.idThreshold;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    query['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  var body : map[string]any = {};
  if (!$isNull(request.facePictureBase64)) {
    body['FacePictureBase64'] = request.facePictureBase64;
  }
  if (!$isNull(request.idOcrPictureBase64)) {
    body['IdOcrPictureBase64'] = request.idOcrPictureBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'EkycVerify',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary ekyc纯服务端接口
 *
 * @param request EkycVerifyRequest
 * @return EkycVerifyResponse
 */
async function ekycVerify(request: EkycVerifyRequest): EkycVerifyResponse {
  var runtime = new $RuntimeOptions{};
  return ekycVerifyWithOptions(request, runtime);
}

model FaceCompareRequest {
  merchantBizId?: string(name='MerchantBizId', example='e0c34a77f5ac40a5aa5e6ed20c353888'),
  sourceFacePicture?: string(name='SourceFacePicture'),
  sourceFacePictureUrl?: string(name='SourceFacePictureUrl', example='https://***face1.jpeg'),
  targetFacePicture?: string(name='TargetFacePicture'),
  targetFacePictureUrl?: string(name='TargetFacePictureUrl', example='https://***face2.jpeg'),
}

model FaceCompareResponseBody = {
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB356FE-BB6A-5DCC-B4C5-E8051787EBA1'),
  result?: {
    faceComparisonScore?: double(name='FaceComparisonScore', example='98'),
    passed?: string(name='Passed', example='Y'),
    transactionId?: string(name='TransactionId', example='08573be80f944d95ac812e019e3655a8'),
  }(name='Result'),
}

model FaceCompareResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: FaceCompareResponseBody(name='body'),
}

/**
 * @summary 人脸比对
 *
 * @param request FaceCompareRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return FaceCompareResponse
 */
async function faceCompareWithOptions(request: FaceCompareRequest, runtime: $RuntimeOptions): FaceCompareResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.sourceFacePictureUrl)) {
    query['SourceFacePictureUrl'] = request.sourceFacePictureUrl;
  }
  if (!$isNull(request.targetFacePictureUrl)) {
    query['TargetFacePictureUrl'] = request.targetFacePictureUrl;
  }
  var body : map[string]any = {};
  if (!$isNull(request.sourceFacePicture)) {
    body['SourceFacePicture'] = request.sourceFacePicture;
  }
  if (!$isNull(request.targetFacePicture)) {
    body['TargetFacePicture'] = request.targetFacePicture;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'FaceCompare',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 人脸比对
 *
 * @param request FaceCompareRequest
 * @return FaceCompareResponse
 */
async function faceCompare(request: FaceCompareRequest): FaceCompareResponse {
  var runtime = new $RuntimeOptions{};
  return faceCompareWithOptions(request, runtime);
}

model FaceGuardRiskRequest {
  bizId?: string(name='BizId', example='LMALL20******001'),
  deviceToken?: string(name='DeviceToken', example='Tk9SSUQuMS*****************ZDNmNWY5NzQxOW1o'),
  merchantBizId?: string(name='MerchantBizId', example='0c83ce0101d34eff886b1f7d1cdef67f'),
  productCode?: string(name='ProductCode', example='FACE_GUARD'),
}

model FaceGuardRiskResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='595E387B-3F0E-5C52-BD02-8EFE63D41FD5'),
  result?: {
    guardRiskScore?: double(name='GuardRiskScore'),
    riskExtends?: string(name='RiskExtends'),
    riskTags?: string(name='RiskTags', example='ROOT,VPN,HOOK'),
    transactionId?: string(name='TransactionId', example='hk573be80f944d95ac812e019e3655a8'),
  }(name='Result'),
}

model FaceGuardRiskResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: FaceGuardRiskResponseBody(name='body'),
}

/**
 * @summary 国际人脸保镖纯服务端接口
 *
 * @param request FaceGuardRiskRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return FaceGuardRiskResponse
 */
async function faceGuardRiskWithOptions(request: FaceGuardRiskRequest, runtime: $RuntimeOptions): FaceGuardRiskResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.bizId)) {
    query['BizId'] = request.bizId;
  }
  if (!$isNull(request.deviceToken)) {
    query['DeviceToken'] = request.deviceToken;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'FaceGuardRisk',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 国际人脸保镖纯服务端接口
 *
 * @param request FaceGuardRiskRequest
 * @return FaceGuardRiskResponse
 */
async function faceGuardRisk(request: FaceGuardRiskRequest): FaceGuardRiskResponse {
  var runtime = new $RuntimeOptions{};
  return faceGuardRiskWithOptions(request, runtime);
}

model FaceLivenessRequest {
  crop?: string(name='Crop', example='T'),
  facePictureBase64?: string(name='FacePictureBase64'),
  facePictureUrl?: string(name='FacePictureUrl', example='https://digital-face-prod8.oss-cn-hangzhou.aliyuncs.com/1669520556530-expo/default/face/20221127114236530_w3kx2e6t.jpg'),
  faceQuality?: string(name='FaceQuality', example='T'),
  merchantBizId?: string(name='MerchantBizId', example='e0c34a77f5ac40a5aa5e6ed20c353888'),
  merchantUserId?: string(name='MerchantUserId', example='123456789'),
  occlusion?: string(name='Occlusion', example='T'),
  productCode?: string(name='ProductCode', example='FACE_LIVENESS_MIN'),
}

model FaceLivenessResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='42EA58CA-5DF4-55D5-82C4-5E7A40DA62BA'),
  result?: {
    extFaceInfo?: {
      faceAge?: int32(name='FaceAge'),
      faceAttack?: string(name='FaceAttack', example='Y'),
      faceGender?: string(name='FaceGender'),
      faceQualityScore?: double(name='FaceQualityScore', example='87.19'),
      occlusionResult?: string(name='OcclusionResult', example='Y'),
    }(name='ExtFaceInfo'),
    passed?: string(name='Passed', example='N'),
    subCode?: string(name='SubCode', example='205'),
    transactionId?: string(name='TransactionId', example='08573be80f944d95ac812e019e3655a8'),
  }(name='Result'),
}

model FaceLivenessResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: FaceLivenessResponseBody(name='body'),
}

/**
 * @summary 静默活体API 纯服务端
 *
 * @param request FaceLivenessRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return FaceLivenessResponse
 */
async function faceLivenessWithOptions(request: FaceLivenessRequest, runtime: $RuntimeOptions): FaceLivenessResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.crop)) {
    query['Crop'] = request.crop;
  }
  if (!$isNull(request.facePictureUrl)) {
    query['FacePictureUrl'] = request.facePictureUrl;
  }
  if (!$isNull(request.faceQuality)) {
    query['FaceQuality'] = request.faceQuality;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    query['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.occlusion)) {
    query['Occlusion'] = request.occlusion;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  var body : map[string]any = {};
  if (!$isNull(request.facePictureBase64)) {
    body['FacePictureBase64'] = request.facePictureBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'FaceLiveness',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 静默活体API 纯服务端
 *
 * @param request FaceLivenessRequest
 * @return FaceLivenessResponse
 */
async function faceLiveness(request: FaceLivenessRequest): FaceLivenessResponse {
  var runtime = new $RuntimeOptions{};
  return faceLivenessWithOptions(request, runtime);
}

model FraudResultCallBackRequest {
  certifyId?: string(name='CertifyId', example='shs2b27333914876c01de4cb22f5841f'),
  extParams?: string(name='ExtParams'),
  resultCode?: string(name='ResultCode', example='PASS'),
  verifyDeployEnv?: string(name='VerifyDeployEnv', example='production'),
}

model FraudResultCallBackResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='4EB35****87EBA1'),
  success?: boolean(name='Success', example='true'),
}

model FraudResultCallBackResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: FraudResultCallBackResponseBody(name='body'),
}

/**
 * @summary 防伪回调接口
 *
 * @param request FraudResultCallBackRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return FraudResultCallBackResponse
 */
async function fraudResultCallBackWithOptions(request: FraudResultCallBackRequest, runtime: $RuntimeOptions): FraudResultCallBackResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.certifyId)) {
    query['CertifyId'] = request.certifyId;
  }
  if (!$isNull(request.extParams)) {
    query['ExtParams'] = request.extParams;
  }
  if (!$isNull(request.resultCode)) {
    query['ResultCode'] = request.resultCode;
  }
  if (!$isNull(request.verifyDeployEnv)) {
    query['VerifyDeployEnv'] = request.verifyDeployEnv;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'FraudResultCallBack',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 防伪回调接口
 *
 * @param request FraudResultCallBackRequest
 * @return FraudResultCallBackResponse
 */
async function fraudResultCallBack(request: FraudResultCallBackRequest): FraudResultCallBackResponse {
  var runtime = new $RuntimeOptions{};
  return fraudResultCallBackWithOptions(request, runtime);
}

model Id2MetaPeriodVerifyIntlRequest {
  docName?: string(name='DocName', description='This parameter is required.'),
  docNo?: string(name='DocNo', description='This parameter is required.', example='411xxxxxxxxxxx0001'),
  docType?: string(name='DocType', description='This parameter is required.', example='​00000001'),
  merchantBizId?: string(name='MerchantBizId', description='This parameter is required.', example='e0c34a77f5ac40a5aa5e6ed20c35****'),
  merchantUserId?: string(name='MerchantUserId', example='1234567890'),
  productCode?: string(name='ProductCode', description='This parameter is required.', example='eKYC_Date_MIN'),
  sceneCode?: string(name='SceneCode', example='1234567890'),
  validityEndDate?: string(name='ValidityEndDate', description='This parameter is required.', example='20301001'),
  validityStartDate?: string(name='ValidityStartDate', description='This parameter is required.', example='20201001'),
}

model Id2MetaPeriodVerifyIntlResponseBody = {
  code?: string(name='Code', example='success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='7B97D932-7FF5-517D-BF39-7CA1BEE3CDD9'),
  result?: {
    passed?: string(name='Passed', example='Y'),
    subCode?: string(name='SubCode', example='200'),
  }(name='Result'),
}

model Id2MetaPeriodVerifyIntlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: Id2MetaPeriodVerifyIntlResponseBody(name='body'),
}

/**
 * @summary 身份二要素有效期核验
 *
 * @param request Id2MetaPeriodVerifyIntlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return Id2MetaPeriodVerifyIntlResponse
 */
async function id2MetaPeriodVerifyIntlWithOptions(request: Id2MetaPeriodVerifyIntlRequest, runtime: $RuntimeOptions): Id2MetaPeriodVerifyIntlResponse {
  request.validate();
  var body : map[string]any = {};
  if (!$isNull(request.docName)) {
    body['DocName'] = request.docName;
  }
  if (!$isNull(request.docNo)) {
    body['DocNo'] = request.docNo;
  }
  if (!$isNull(request.docType)) {
    body['DocType'] = request.docType;
  }
  if (!$isNull(request.merchantBizId)) {
    body['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    body['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.productCode)) {
    body['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.sceneCode)) {
    body['SceneCode'] = request.sceneCode;
  }
  if (!$isNull(request.validityEndDate)) {
    body['ValidityEndDate'] = request.validityEndDate;
  }
  if (!$isNull(request.validityStartDate)) {
    body['ValidityStartDate'] = request.validityStartDate;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'Id2MetaPeriodVerifyIntl',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 身份二要素有效期核验
 *
 * @param request Id2MetaPeriodVerifyIntlRequest
 * @return Id2MetaPeriodVerifyIntlResponse
 */
async function id2MetaPeriodVerifyIntl(request: Id2MetaPeriodVerifyIntlRequest): Id2MetaPeriodVerifyIntlResponse {
  var runtime = new $RuntimeOptions{};
  return id2MetaPeriodVerifyIntlWithOptions(request, runtime);
}

model Id2MetaVerifyIntlRequest {
  identifyNum?: string(name='IdentifyNum', example='429001********8211'),
  paramType?: string(name='ParamType', example='normal'),
  productCode?: string(name='ProductCode', example='ID_2META'),
  userName?: string(name='UserName'),
}

model Id2MetaVerifyIntlResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='EFA11401-C961-5E89-A2D3-BF9883E5CC3D'),
  result?: {
    bizCode?: string(name='BizCode', example='1'),
  }(name='Result'),
}

model Id2MetaVerifyIntlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: Id2MetaVerifyIntlResponseBody(name='body'),
}

/**
 * @summary 身份二要素国际版接口
 *
 * @param request Id2MetaVerifyIntlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return Id2MetaVerifyIntlResponse
 */
async function id2MetaVerifyIntlWithOptions(request: Id2MetaVerifyIntlRequest, runtime: $RuntimeOptions): Id2MetaVerifyIntlResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.identifyNum)) {
    query['IdentifyNum'] = request.identifyNum;
  }
  if (!$isNull(request.paramType)) {
    query['ParamType'] = request.paramType;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.userName)) {
    query['UserName'] = request.userName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'Id2MetaVerifyIntl',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 身份二要素国际版接口
 *
 * @param request Id2MetaVerifyIntlRequest
 * @return Id2MetaVerifyIntlResponse
 */
async function id2MetaVerifyIntl(request: Id2MetaVerifyIntlRequest): Id2MetaVerifyIntlResponse {
  var runtime = new $RuntimeOptions{};
  return id2MetaVerifyIntlWithOptions(request, runtime);
}

model InitializeRequest {
  appQualityCheck?: string(name='AppQualityCheck'),
  authorize?: string(name='Authorize'),
  callbackToken?: string(name='CallbackToken'),
  callbackUrl?: string(name='CallbackUrl'),
  crop?: string(name='Crop', example='*'),
  dateOfBirth?: string(name='DateOfBirth'),
  dateOfExpiry?: string(name='DateOfExpiry'),
  docPageConfig?: [ string ](name='DocPageConfig'),
  docScanMode?: string(name='DocScanMode'),
  docType?: string(name='DocType', example='01000000'),
  docVideo?: string(name='DocVideo'),
  documentNumber?: string(name='DocumentNumber'),
  experienceCode?: string(name='ExperienceCode'),
  facePictureBase64?: string(name='FacePictureBase64'),
  facePictureUrl?: string(name='FacePictureUrl', example='***'),
  idFaceQuality?: string(name='IdFaceQuality', example='*'),
  idSpoof?: string(name='IdSpoof', example='Y'),
  idThreshold?: string(name='IdThreshold'),
  languageConfig?: string(name='LanguageConfig'),
  MRTDInput?: string(name='MRTDInput'),
  merchantBizId?: string(name='MerchantBizId', example='e0c34a***353888'),
  merchantUserId?: string(name='MerchantUserId', example='1221****6543'),
  metaInfo?: string(name='MetaInfo', example='{\\\\"bioMetaInfo\\\\":\\\\"4.1.0:2916352,0\\\\",\\\\"deviceType\\\\":\\\\"web\\\\",\\\\"ua\\\\":\\\\"Mozilla/5.0 (Macintosh'),
  model?: string(name='Model'),
  ocr?: string(name='Ocr', description='OCR。', example='*'),
  procedurePriority?: string(name='ProcedurePriority'),
  productCode?: string(name='ProductCode', example='eKYC'),
  productFlow?: string(name='ProductFlow'),
  returnUrl?: string(name='ReturnUrl', example='http*****'),
  sceneCode?: string(name='SceneCode', example='PAY**'),
  securityLevel?: string(name='SecurityLevel'),
  showAlbumIcon?: string(name='ShowAlbumIcon'),
  showGuidePage?: string(name='ShowGuidePage'),
  showOcrResult?: string(name='ShowOcrResult'),
  styleConfig?: string(name='StyleConfig'),
  useNFC?: string(name='UseNFC'),
}

model InitializeShrinkRequest {
  appQualityCheck?: string(name='AppQualityCheck'),
  authorize?: string(name='Authorize'),
  callbackToken?: string(name='CallbackToken'),
  callbackUrl?: string(name='CallbackUrl'),
  crop?: string(name='Crop', example='*'),
  dateOfBirth?: string(name='DateOfBirth'),
  dateOfExpiry?: string(name='DateOfExpiry'),
  docPageConfigShrink?: string(name='DocPageConfig'),
  docScanMode?: string(name='DocScanMode'),
  docType?: string(name='DocType', example='01000000'),
  docVideo?: string(name='DocVideo'),
  documentNumber?: string(name='DocumentNumber'),
  experienceCode?: string(name='ExperienceCode'),
  facePictureBase64?: string(name='FacePictureBase64'),
  facePictureUrl?: string(name='FacePictureUrl', example='***'),
  idFaceQuality?: string(name='IdFaceQuality', example='*'),
  idSpoof?: string(name='IdSpoof', example='Y'),
  idThreshold?: string(name='IdThreshold'),
  languageConfig?: string(name='LanguageConfig'),
  MRTDInput?: string(name='MRTDInput'),
  merchantBizId?: string(name='MerchantBizId', example='e0c34a***353888'),
  merchantUserId?: string(name='MerchantUserId', example='1221****6543'),
  metaInfo?: string(name='MetaInfo', example='{\\\\"bioMetaInfo\\\\":\\\\"4.1.0:2916352,0\\\\",\\\\"deviceType\\\\":\\\\"web\\\\",\\\\"ua\\\\":\\\\"Mozilla/5.0 (Macintosh'),
  model?: string(name='Model'),
  ocr?: string(name='Ocr', description='OCR。', example='*'),
  procedurePriority?: string(name='ProcedurePriority'),
  productCode?: string(name='ProductCode', example='eKYC'),
  productFlow?: string(name='ProductFlow'),
  returnUrl?: string(name='ReturnUrl', example='http*****'),
  sceneCode?: string(name='SceneCode', example='PAY**'),
  securityLevel?: string(name='SecurityLevel'),
  showAlbumIcon?: string(name='ShowAlbumIcon'),
  showGuidePage?: string(name='ShowGuidePage'),
  showOcrResult?: string(name='ShowOcrResult'),
  styleConfig?: string(name='StyleConfig'),
  useNFC?: string(name='UseNFC'),
}

model InitializeResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', description='Id of the request', example='4EB35****87EBA1'),
  result?: {
    clientCfg?: string(name='ClientCfg', example='***'),
    transactionId?: string(name='TransactionId', example='08573be80f944d95ac812e019e3655a8'),
    transactionUrl?: string(name='TransactionUrl', example='http****'),
  }(name='Result'),
}

model InitializeResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: InitializeResponseBody(name='body'),
}

/**
 * @summary 认证初始化
 *
 * @param tmpReq InitializeRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return InitializeResponse
 */
async function initializeWithOptions(tmpReq: InitializeRequest, runtime: $RuntimeOptions): InitializeResponse {
  tmpReq.validate();
  var request = new InitializeShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!$isNull(tmpReq.docPageConfig)) {
    request.docPageConfigShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.docPageConfig, 'DocPageConfig', 'json');
  }
  var query = {};
  if (!$isNull(request.appQualityCheck)) {
    query['AppQualityCheck'] = request.appQualityCheck;
  }
  if (!$isNull(request.authorize)) {
    query['Authorize'] = request.authorize;
  }
  if (!$isNull(request.callbackToken)) {
    query['CallbackToken'] = request.callbackToken;
  }
  if (!$isNull(request.callbackUrl)) {
    query['CallbackUrl'] = request.callbackUrl;
  }
  if (!$isNull(request.crop)) {
    query['Crop'] = request.crop;
  }
  if (!$isNull(request.dateOfBirth)) {
    query['DateOfBirth'] = request.dateOfBirth;
  }
  if (!$isNull(request.dateOfExpiry)) {
    query['DateOfExpiry'] = request.dateOfExpiry;
  }
  if (!$isNull(request.docPageConfigShrink)) {
    query['DocPageConfig'] = request.docPageConfigShrink;
  }
  if (!$isNull(request.docScanMode)) {
    query['DocScanMode'] = request.docScanMode;
  }
  if (!$isNull(request.docType)) {
    query['DocType'] = request.docType;
  }
  if (!$isNull(request.docVideo)) {
    query['DocVideo'] = request.docVideo;
  }
  if (!$isNull(request.documentNumber)) {
    query['DocumentNumber'] = request.documentNumber;
  }
  if (!$isNull(request.experienceCode)) {
    query['ExperienceCode'] = request.experienceCode;
  }
  if (!$isNull(request.facePictureUrl)) {
    query['FacePictureUrl'] = request.facePictureUrl;
  }
  if (!$isNull(request.idFaceQuality)) {
    query['IdFaceQuality'] = request.idFaceQuality;
  }
  if (!$isNull(request.idSpoof)) {
    query['IdSpoof'] = request.idSpoof;
  }
  if (!$isNull(request.idThreshold)) {
    query['IdThreshold'] = request.idThreshold;
  }
  if (!$isNull(request.languageConfig)) {
    query['LanguageConfig'] = request.languageConfig;
  }
  if (!$isNull(request.MRTDInput)) {
    query['MRTDInput'] = request.MRTDInput;
  }
  if (!$isNull(request.merchantBizId)) {
    query['MerchantBizId'] = request.merchantBizId;
  }
  if (!$isNull(request.merchantUserId)) {
    query['MerchantUserId'] = request.merchantUserId;
  }
  if (!$isNull(request.metaInfo)) {
    query['MetaInfo'] = request.metaInfo;
  }
  if (!$isNull(request.model)) {
    query['Model'] = request.model;
  }
  if (!$isNull(request.ocr)) {
    query['Ocr'] = request.ocr;
  }
  if (!$isNull(request.procedurePriority)) {
    query['ProcedurePriority'] = request.procedurePriority;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.productFlow)) {
    query['ProductFlow'] = request.productFlow;
  }
  if (!$isNull(request.returnUrl)) {
    query['ReturnUrl'] = request.returnUrl;
  }
  if (!$isNull(request.sceneCode)) {
    query['SceneCode'] = request.sceneCode;
  }
  if (!$isNull(request.securityLevel)) {
    query['SecurityLevel'] = request.securityLevel;
  }
  if (!$isNull(request.showAlbumIcon)) {
    query['ShowAlbumIcon'] = request.showAlbumIcon;
  }
  if (!$isNull(request.showGuidePage)) {
    query['ShowGuidePage'] = request.showGuidePage;
  }
  if (!$isNull(request.showOcrResult)) {
    query['ShowOcrResult'] = request.showOcrResult;
  }
  if (!$isNull(request.styleConfig)) {
    query['StyleConfig'] = request.styleConfig;
  }
  if (!$isNull(request.useNFC)) {
    query['UseNFC'] = request.useNFC;
  }
  var body : map[string]any = {};
  if (!$isNull(request.facePictureBase64)) {
    body['FacePictureBase64'] = request.facePictureBase64;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApiUtil.Params{
    action = 'Initialize',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 认证初始化
 *
 * @param request InitializeRequest
 * @return InitializeResponse
 */
async function initialize(request: InitializeRequest): InitializeResponse {
  var runtime = new $RuntimeOptions{};
  return initializeWithOptions(request, runtime);
}

model Mobile3MetaVerifyIntlRequest {
  identifyNum?: string(name='IdentifyNum', example='429001********8211'),
  mobile?: string(name='Mobile', example='186****1234'),
  paramType?: string(name='ParamType', example='normal'),
  productCode?: string(name='ProductCode', example='MOBILE_3META'),
  userName?: string(name='UserName'),
}

model Mobile3MetaVerifyIntlResponseBody = {
  code?: string(name='Code', example='Success'),
  message?: string(name='Message', example='success'),
  requestId?: string(name='RequestId', example='D241532C-4EE9-5A2A-A5A5-C1FD98CE2EDD'),
  result?: {
    bizCode?: string(name='BizCode', example='1'),
    ispName?: string(name='IspName', example='CMCC'),
    subCode?: string(name='SubCode', example='101'),
  }(name='Result'),
}

model Mobile3MetaVerifyIntlResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: Mobile3MetaVerifyIntlResponseBody(name='body'),
}

/**
 * @summary 手机号三要素国际版接口
 *
 * @param request Mobile3MetaVerifyIntlRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return Mobile3MetaVerifyIntlResponse
 */
async function mobile3MetaVerifyIntlWithOptions(request: Mobile3MetaVerifyIntlRequest, runtime: $RuntimeOptions): Mobile3MetaVerifyIntlResponse {
  request.validate();
  var query = {};
  if (!$isNull(request.identifyNum)) {
    query['IdentifyNum'] = request.identifyNum;
  }
  if (!$isNull(request.mobile)) {
    query['Mobile'] = request.mobile;
  }
  if (!$isNull(request.paramType)) {
    query['ParamType'] = request.paramType;
  }
  if (!$isNull(request.productCode)) {
    query['ProductCode'] = request.productCode;
  }
  if (!$isNull(request.userName)) {
    query['UserName'] = request.userName;
  }
  var req = new OpenApiUtil.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApiUtil.Params{
    action = 'Mobile3MetaVerifyIntl',
    version = '2022-08-09',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

/**
 * @summary 手机号三要素国际版接口
 *
 * @param request Mobile3MetaVerifyIntlRequest
 * @return Mobile3MetaVerifyIntlResponse
 */
async function mobile3MetaVerifyIntl(request: Mobile3MetaVerifyIntlRequest): Mobile3MetaVerifyIntlResponse {
  var runtime = new $RuntimeOptions{};
  return mobile3MetaVerifyIntlWithOptions(request, runtime);
}

